'''
import multiprocessing

def worker_function(name):
    print(f"Worker {name} is starting.")    
    print(f"Worker {name} is finishing.")

if __name__ == "__main__":
    process = multiprocessing.Process(target=worker_function, args=("Process-1",))
    # 创建进程
    process.start()  #启动进程
    print("Main process is finishing.")






import threading
import time
tickets = 10
lock = threading.Lock()
def sell_tickets(thread_name):
    global tickets
    while True:
        lock.acquire()
        try:
            if tickets > 0:
                time.sleep(0.1)  
                print(f"{thread_name} 售出第 {11 - tickets} 张票，剩余 {tickets - 1} 张票。")
                tickets -= 1
            else:
                print(f"{thread_name} 没有车票可售了。")
                break
        finally:
              lock.release()
thread1 = threading.Thread(target=sell_tickets, args=("线程1",))
thread2 = threading.Thread(target=sell_tickets, args=("线程2",))
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print("所有车票已售罄。")


'''
#开启摄像头

import cv2
capture = cv2.VideoCapture(0)
while (capture.isOpened()):
    ret,frame = capture.read()
    if ret == True:
        cv2.namedWindow('My photo',0)
        cv2.imshow('My photo', frame)
        if cv2.waitKey(1) & 0xff ==ord('q'):
            cv2.imwrite('',frame)
            break
capture.release()
cv2.waitKey(0)



